package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itheima.dao.UserDao;
import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;


    public boolean add(User user) {
        return userDao.add(user);
    }



    public boolean delete(Integer id) {
        return userDao.delete(id);
    }



    public boolean update(User user) {
        return userDao.update(user);
    }



    @Transactional(readOnly = true)
    public User findById(Integer id) {
        return userDao.findById(id);
    }



    public PageInfo findAll(int page, int size) {
        PageHelper.startPage(page,size);
        List<User> all = userDao.findAll(page, size);
        PageInfo pageInfo=new PageInfo(all);
        return pageInfo;
    }
}
